import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { ObjCreate } from "../common/ObjCreate";
import { SecondCareerItem } from "./selectSubWin/SecondCareerItem";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ImagesConst } from "../../resource/ImagesConst";
import { SecTimerView } from "../common/SecTimerView";
import { GTextFormat } from "../../../common/GTextFormat";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ConstConfig } from "../../resource/ConstConfig";
import { GlobalSkin } from "../../../component/skin/GlobalSkin";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ImageInfo } from "../../../../com/gengine/resource/info/ImageInfo";
import { RuneMapPanel } from "../skill/rune/RuneMapPanel";
import { GButton } from "../../../../com/mui/controls/GButton";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
type int = number;
//class SecondCareerTransformWin
    
    export  class SecondCareerTransformWin extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(485, 433);
            this.title = Language.getString(80204);
            this.titleHeight = 27;
            this._btn.addEventListener(flash.events.MouseEvent.CLICK, this.clickTransformHandler);
            return;
        }

        public updateView(arg1: int, arg2: int, arg3: int, arg4: int, arg5: Boolean): void
        {
            this._baseItem.update(arg1);
            this._secondItem.update(arg2);
            if (arg3 != arg1) 
            {
                this._already.x = this._secondItem.x - 10;
            }
            else 
            {
                this._already.x = this._baseItem.x - 10;
            }
            var loc1=arg4.toString();
            if (arg5) 
            {
                loc1 = HTMLUtil.addColor(loc1, "#FEFDB4");
            }
            else 
            {
                loc1 = HTMLUtil.addColor(loc1, "#ff000");
            }
            this._txtNeedCoin.htmlText = Language.getStringByParam(80250, loc1);
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc2=null;
            super.createChildren();
            ObjCreate.createFlowerBg(18, 39, 449, 283, this);
            this._baseItem = new SecondCareerItem();
            this._baseItem.x = 61;
            this._baseItem.y = 86;
            this.addChild(this._baseItem);
            this._btTra = new Object /* flash.display.Bitmap */();
            this._btTra.x = 221;
            this._btTra.y = 125;
            this.addChild(this._btTra);
            LoaderManager.instance.load("SecondCareerExchangeLabel.png", this.onTranLoaded);
            this._secondItem = new SecondCareerItem();
            this._secondItem.x = 283;
            this._secondItem.y = 86;
            this.addChild(this._secondItem);
            this._already = new Object /* flash.display.Bitmap */();
            this._already.x = 210;
            this._already.y = 76;
            this.addChild(this._already);
            LoaderHelp.setBitmapdata("SecondCareerActived.png", this._already);
            ObjCreate.createBg(140, 228, 200, 24, this, ImagesConst.SelectedBg);
            this._cdTimeView = new SecTimerView();
            this._cdTimeView.x = 140;
            this._cdTimeView.y = 230;
            this._cdTimeView.width = 200;
            this._cdTimeView.height = 20;
            this._cdTimeView.defaultTextFormat = new GTextFormat(null, 14, 16776960, null, null, null, null, null, flash.text.TextFormatAlign.CENTER);
            this._cdTimeView.filters = [FilterConst.glowFilter];
            this._cdTimeView.setParse(HTMLUtil.addColor(Language.getString(80248), "#FFFF00"));
            this.addChild(this._cdTimeView);
            this._txtNeedCoin = ObjCreate.createGTextField("", 140, 260, 200, 20, this);
            var loc1=this._txtNeedCoin.defaultTextFormat;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._txtNeedCoin.defaultTextFormat = loc1;
            loc2 = GlobalClass.getBitmap("Tongqian_bind");
            loc2.x = 280;
            loc2.y = this._txtNeedCoin.y - 2;
            this.addChild(loc2);
            this._btn = ObjCreate.createGButton("", 196, 284, 77, 28, this, "ButtonRed");
            this._btn.label = Language.getString(80203);
            ObjCreate.createBg(18, 322, 449, 98, this);
            this._txtDesc = ObjCreate.createGTextField("", 23, 330, 438, 100, this);
            loc1 = this._txtDesc.defaultTextFormat;
            loc1.leading = 5;
            this._txtDesc.defaultTextFormat = loc1;
            this._txtDesc.multiline = true;
            this._txtDesc.wordWrap = true;
            var loc3=int(ConstConfig.instance.getValueByName("CareerSecondSwitchCD") / 60);
            this._txtDesc.htmlText = Language.getStringByParam(80230, loc3);
            this._runeMapLink = ObjCreate.createGButton(Language.getString(61501), 379, 330, 75, 26, this, GlobalSkin.ButtonSpecial);
            this._runeMapLink.addEventListener(flash.events.MouseEvent.CLICK, this.onRuneMapLinkClick);
            return;
        }

        /* internal  */clickTransformHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SecondCareerTransfrom, {}));
            return;
        }

        /* internal  */onTranLoaded(arg1: ImageInfo): void
        {
            this._btTra.bitmapData = arg1.bitmapData;
            return;
        }

        public updateCdTime(arg1: int): void
        {
            this._cdTimeView.setLeftTime(arg1);
            return;
        }

        /* internal  */onRuneMapLinkClick(arg1): void
        {
            if (this._runeMapPanel && this._runeMapPanel.parent) 
            {
                this.hideRuneMapPanel();
            }
            else 
            {
                this.showRuneMapPanel();
            }
            return;
        }

        public showRuneMapPanel(): void
        {
            if (!this._runeMapPanel) 
            {
                this._runeMapPanel = new RuneMapPanel();
                this._runeMapPanel.x = 480;
                this._runeMapPanel.y = 30;
                this._runeMapPanel.setHight(400);
            }
            this.addChild(this._runeMapPanel);
            return;
        }

        public hideRuneMapPanel(): void
        {
            if (this._runeMapPanel && this._runeMapPanel.parent) 
            {
                this._runeMapPanel.parent.removeChild(this._runeMapPanel);
            }
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this.hideRuneMapPanel();
            return;
        }

        /* internal */ /* var */_btn: GButton;

        /* internal */ /* var */_baseItem: SecondCareerItem;

        /* internal */ /* var */_secondItem: SecondCareerItem;

        /* internal */ /* var */_btTra: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_already: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_txtNeedCoin: GTextFiled;

        /* internal */ /* var */_txtDesc: GTextFiled;

        /* internal */ /* var */_cdTimeView: SecTimerView;

        /* internal */ /* var */_runeMapLink: GButton;

        /* internal */ /* var */_runeMapPanel: RuneMapPanel;
    }
